Move the registration of the @releaseDomain watch so that we avoid a watch
authoremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Wed, 16 Nov 2005 14:27:11 +0000 (15:27 +0100)
committeremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Wed, 16 Nov 2005 14:27:11 +0000 (15:27 +0100)
between the watch firing and the first call to refresh.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/python/xen/xend/XendDomain.py

index 5bc1a698f6017b71f7b94175826181c25732723b..389e6114a36a973698087885c1385f7a6b1451be 100644 (file)
@@ -63,14 +63,19 @@ class XendDomain:
         self.domains = {}
         self.domains_lock = threading.RLock()
 
-        xswatch("@releaseDomain", self.onReleaseDomain)
-
         self.domains_lock.acquire()
         try:
             self._add_domain(
                 XendDomainInfo.recreate(self.xen_domains()[PRIV_DOMAIN],
                                         True))
             self.dom0_setup()
+
+            # This watch registration needs to be before the refresh call, so
+            # that we're sure that we haven't missed any releases, but inside
+            # the domains_lock, as we don't want the watch to fire until after
+            # the refresh call has completed.
+            xswatch("@releaseDomain", self.onReleaseDomain)
+            
             self.refresh(True)
         finally:
             self.domains_lock.release()